package com.lovo.homework;

import com.lovo.homework.util.Util;

public class GuessGame {
    private Player player = new Player();
    private Computer computer = new Computer();
    public void run(){
        for(int i = 0;i < 10;i++){
            int computerValue = computer.generate();
            int playerValue = player.generate();
            System.out.println("电脑出：" + Util.showResult(computerValue));
            System.out.println("玩家出：" + Util.showResult(playerValue));
            if(computerValue > playerValue){
                if(computerValue - playerValue == 2){
                    System.out.println("玩家赢");
                    player.setScore(player.getScore() + 1);
                    computer.setScore(computer.getScore() - 1);
                }else{
                    System.out.println("电脑赢");
                    player.setScore(player.getScore() - 1);
                    computer.setScore(computer.getScore() + 1);
                }
            }else if(computerValue < playerValue){
                if(playerValue - computerValue == 2){
                    System.out.println("电脑赢");
                    player.setScore(player.getScore() - 1);
                    computer.setScore(computer.getScore() + 1);
                }else{
                    System.out.println("玩家赢");
                    player.setScore(player.getScore() + 1);
                    computer.setScore(computer.getScore() - 1);
                }
            }else{
                System.out.println("平局");
            }

        }
        System.out.println("玩家分数：" + player.getScore());
        System.out.println("电脑分数：" + computer.getScore());
    }
    public static void main(String[] args) {
        GuessGame game = new GuessGame();
        game.run();
    }
}
